package com.gnerv.pabu.plugin.mybatis.plus;

import org.apache.commons.lang.StringUtils;

public class PrefixSuffix {

    public static final String CONTROLLER = "Controller";
    public static final String I_SERVICE = "I";
    public static final String SERVICE_IMPL = "ServiceImpl";
    public static final String MAPPER = "Mapper";

    public static final String DTO = "DTO";
    public static final String[] SUFFIX = {".java", ".xml"};

    public static String controller(String name) {
        return createName(name, CONTROLLER, SUFFIX[0]);
    }

    public static String service(String name) {
        return createName(I_SERVICE, name, SUFFIX[0]);
    }

    public static String serviceImpl(String name) {
        return createName(name, SERVICE_IMPL, SUFFIX[0]);
    }

    public static String mapper(String name) {
        return createName(name, MAPPER, SUFFIX[0]);
    }

    public static String mapperXml(String name) {
        return createName(name, MAPPER, SUFFIX[1]);
    }

    public static String dto(String name) {
        return createName(name, DTO, SUFFIX[0]);
    }

    private static String createName(String strOne, String strTwo, String suffix) {
        if (StringUtils.isNotEmpty(strOne) && StringUtils.isNotEmpty(strTwo)) {
            return strOne + strTwo + suffix;
        }
        return null;
    }

}
